package org.zhuxian.cn.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.zhuxian.cn.common.ErrorCode;
import org.zhuxian.cn.result.JsonResult;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    public JsonResult runtimeExceptionHandler(RuntimeException e) {
        log.error("RuntimeException", e);
        return new JsonResult(ErrorCode.SYSTEM_ERROR.getCode(), e.getMessage());
    }
}
